/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.util.Collections;
import javafx.collections.ObservableList;
import javafx.scene.control.TextField;

/**
 *
 * @author Joseph
 */
public class TextFieldValidation {

    public static void setRed(TextField tf) {
        ObservableList<String> styleClass = tf.getStyleClass();
        boolean bool = tf.getText().trim().isEmpty();
        if (!styleClass.contains("tferror")) {
            if (bool) {
                styleClass.add("tferror");
            }
        } else if (styleClass.contains("tferror") && !bool) {
            removeRed(tf);
        }
    }

    public static void removeRed(TextField tf) {
        ObservableList<String> styleClass = tf.getStyleClass();
        styleClass.removeAll(Collections.singleton("tferror"));
    }

    private TextFieldValidation() {
    }
}
